package com.sirun.ble.enums;

/**
 * @author : hzw
 * ICCE状态及自定义业务状态STATUS枚举
 *
 * ICCE状态STATUS由TLV格式Response的Payload中返回, 长度1字节
 *
 * 01~0F 系统类错误, 0x09~0x0F 保留值
 * 10~1F 通信类错误
 * 20~FF 业务类错误, 预留给业务定义
 *
 * 自定义缩写
 * COMM ( COMMUNICATION通信 )
 * SYS ( SYSTEN系统 )
 * CONN ( CONNECT连接 )
 * ERR ( ERROR错误 )
 */
public enum IcceStatusEnum {

    /** ================================================ 通用(ICCE规定.成功) ================================================ */
    SUCCESS(0, "成功"),

    /** ================================================ 错误(ICCE规定.系统类, 01~0F) ================================================ */
    ERR_SYS_UNKNOWN(1, "未知错误类型"),
    ERR_SYS_MESSAGE(2, "不支持该Message的请求"),
    ERR_SYS_COMMAND(3, "不支持该Command的请求"),
    ERR_SYS_PERMISSION(4, "无权限"),
    ERR_SYS_BUSY(5, "系统忙"),
    ERR_SYS_REQUEST_FORMAT(6, "请求格式错误"),
    ERR_SYS_PAYLOAD_TLV(7, "Payload TLV参数解析错误"),
    ERR_SYS_DEVICE_AUTH(8, "设备认证失败/设备认证状态失效"),

    /** ================================================ 错误(ICCE规定.通信类, 10~1F) ================================================ */
    ERR_COMM_FRAME_SEQUENCE(10, "帧序列错误"),
    ERR_COMM_TIMEOUT(11, "传输超时"),
    ERR_COMM_LENGTH(12, "长度不符"),
    ERR_COMM_CRC(13, "CRC校验错误"),
    ERR_COMM_LOSE_PACKAGE(14, "丢包, 请求重发"),

    /** ================================================ 信息(业务自定义类, 20~FF) ================================================ */
    BIZ_SUCCESS_CONNECT(20, "连接成功"),
    BIZ_SUCCESS_CONNECT_AUTH(21, "已连接并鉴权成功"),
    BIZ_SUCCESS_CONTROL(22, "控车成功"),

    //=================> 通用错误
    BIZ_ERR_COMMON_NET(30, "网络异常"),
    BIZ_ERR_COMMON_INIT(31, "初始化异常"),
    BIZ_ERR_COMMON_CONTEXT_NOT_EXIST(32, "上下文不存在"),
    BIZ_ERR_COMMON_BLE_NOT_SUPPORT(33, "设备不支持蓝牙"),
    BIZ_ERR_COMMON_SYS_CLOSED(34, "系统蓝牙已关闭"),
    BIZ_ERR_COMMON_GPS_CLOSED(35, "GPS位置开关已关闭"),
    BIZ_ERR_CONNECT_FAIL_DISTANCE(36, "连接失败，设备连接距离过远或设备已被其他设备连接"),
    BIZ_ERR_COMMON_VIN_NONE(37, "VIN不可为空"),
    BIZ_ERR_COMMON_PERMISSION_STORAGE(38, "无读写权限"),
    BIZ_ERR_COMMON_PERMISSION_LOCATION(39, "无位置权限"),
    BIZ_ERR_COMMON_PERMISSION_BLUETOOTH(40, "无蓝牙权限"),
    BIZ_ERR_COMMON_BLE_SERVICE_OPEN_FAIL(41, "蓝牙服务开启失败"),
    BIZ_ERR_COMMON_ENV_ABNORMAL(42, "安全环境异常"),
    BIZ_ERR_COMMON_CERT_ABNORMAL(43, "证书获取异常"),

    //=================> 连接错误
    BIZ_ERR_CONN_AUTH_FAIL(60, "连接失败，鉴权未通过"),
    BIZ_ERR_CONN_FAIL_SYS_ABOUT(61, "连接失败，系统底层原因未知"),
    BIZ_ERR_CONN_FAIL_FREQUENTLY(62, "连接失败，连接过于频繁，请稍后尝试"),
    BIZ_ERR_CONN_NONE(63, "蓝牙未连接"),
    BIZ_ERR_CONN_CLOSE(64, "蓝牙连接中断"),
    BIZ_ERR_CONN_FAIL_SEARCH_DEVICE(65, "未搜索到对应蓝牙设备"),
    BIZ_ERR_CONN_FAIL_NO_SERVICE(66, "连接失败，未查找到相关服务"),
    BIZ_ERR_CONN_FAIL_NO_UUID(67, "连接失败，未查找到相关UUID"),
    BIZ_ERR_CONN_FAIL_NOTIFY_OPEN(68, "连接失败，通知服务无法开启"),
    BIZ_ERR_CONN_FAIL_LATER_RETRY(69, "连接失败，请稍后尝试"),

    //=================> 控车错误
    BIZ_ERR_CONTROL_FAIL(80, "控车失败"),
    BIZ_ERR_CONTROL_UNKNOWN_SYS_BLE_CLOSED(81, "系统蓝牙已关闭，控制结果未知");

    public int code;
    public String desc;

    IcceStatusEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }
}
